package org.xyf.workflow.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Part;
import org.flowable.engine.history.HistoricProcessInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xyf.workflow.service.WorkflowService;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/flowableTest")
public class TestController {


    @Resource
    private WorkflowService workflowService;



    @GetMapping("/deploy")
    public String deployProcessDefinition(HttpServletRequest request) throws ServletException, IOException {
        Part part = request.getPart("file");

        return "部署成功";
    }

    @GetMapping("/history")
    public List<HistoricProcessInstance> getHistory() {
        return workflowService.getApprovedHistory("xyf","app_xyf");
    }
}
